package tech.aistar.mapper;

import org.apache.ibatis.annotations.*;
import tech.aistar.entity.UserLogin;

import java.util.List;

public interface UserLoginMapper {

    //根据主键id查找  (封装info信息)
    UserLogin findById(Integer id);

    //修改用户名
    @Update("update user_login set user_name=#{Username} where id=#{id}")
    void editUsername(@Param("Username") String Username,@Param("id")Integer id);

    //根据账户信息查询
    @Select("select * from user_login where user_id = #{value}")
    UserLogin findByUserId(String userId);

    //按照用户名模糊查询
    @Select("select * from user_login where user_name like concat('%',#{value},'%')")
    UserLogin findByName(String userName);

    //添加用户信息
    @Insert("insert into user_login values (#{id},#{userId},#{userPassword},#{userName},#{userStatus},#{powers},#{name},#{numder})")
    @SelectKey(statement="select LAST_INSERT_ID()", keyProperty="id", before=false, resultType=int.class)
    void addUserLogin(UserLogin userLogin);

    //修改用户密码信息
    @Update("update user_login set user_password=#{userPassword} where user_id=#{userId}")
    void editUserLogin(@Param("userId") String userId, @Param("userPassword") String userPassword);

    //删除用户
    @Update("update user_login set user_status = 1 where id = #{value}")
    void delUserLogin(Integer id);

    //实名认证
    @Update("update user_login set name = #{name},numder = #{numder} where user_id = #{userId}")
    void addCard(@Param("name") String name, @Param("numder") String numder, @Param("userId") String userId);

    //获取身份证件集合
    @Select("select numder from user_login")
    List<String> findCards();

    @Select("select count(*) from user_login")
    Integer findByCount();

}
